package tp.pr5.instructions;


import tp.pr5.NavigationModule;
import tp.pr5.RobotEngine;
import tp.pr5.instructions.exceptions.InstructionExecutionException;
import tp.pr5.instructions.exceptions.WrongInstructionFormatException;
import tp.pr5.items.ItemContainer;

public class HelpInstruction extends UndoAble{
	private RobotEngine rbt;
	/**
	 * parses the instruction from the string given
	 */
	@Override
	public Instruction parse(String cad) throws WrongInstructionFormatException {
		if(cad.equalsIgnoreCase("HELP") || cad.equalsIgnoreCase("AYUDA")){//si la acciÃ³n introducida es HELP
			return new HelpInstruction();
		}else{
			throw new WrongInstructionFormatException();			
		}		
	}
	/**
	 * returns instruction help string
	 */
	@Override
	public String getHelp() {
		return "     HELP|AYUDA";
	}
	/**
	 * sets the needed variables
	 */
	@Override
	public void configureContext(RobotEngine engine,
			NavigationModule navigation, ItemContainer robotContainer) {
		this.rbt = engine;
		
	}
	/**
	 * executes the instruction if possible
	 */
	@Override
	public void execute() throws InstructionExecutionException {		
		this.rbt.requestHelp();
	}
	
}
